/**
 * SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
 * SPDX-License-Identifier: Mulan PSL v2
 */
/**
 * @file 服务器常量
 */

// 镜像类型
export const IMAGE_TYPE = {
    standard: 'standard',
    custom: 'custom'
};

// 镜像类型文本
export const IMAGE_TYPE_TEXT = {
    [IMAGE_TYPE.standard]: _('标准'),
    [IMAGE_TYPE.custom]: _('自定义')
};

// 硬件信息单位
export const HARDWARE_UNIT_LIST = [
    {
        id: 'KB',
        text: 'KB'
    }, {
        id: 'MB',
        text: 'MB'
    }, {
        id: 'GB',
        text: 'GB'
    }, {
        id: 'TB',
        text: 'TB'
    }
];

// notebooks 的状态映射
export const NOTE_STATUS_MAP = {
    icon: {
        running: '',
        starting: 'iconjiazaiicon icon iconfont',
        delLoading: 'iconjiazaiicon icon iconfont',
        failed: 'iconcross-circle icon iconfont',
        stopped: 'iconzanting'
    },
    text: {
        running: _('正在运行'),
        starting: _('正在启动'),
        delLoading: _('正在删除'),
        failed: _('已失败'),
        stopped: _('已停止')
    },
    cls: {
        running: 'sv-running',
        starting: 'sv-loading',
        delLoading: 'sv-delete-loading',
        failed: 'sv-file',
        stopped: 'sv-stopped'
    },
    status: {
        running: 'running',
        starting: 'starting',
        delLoading: 'delLoading',
        failed: 'failed',
        stopped: 'stopped'
    }
};

export function getNoteStatus (record) {

    let { pending, ready } = record;

    // 正在删除，该状态当点击删除时触发
    if (pending === 'deleting') {
        return NOTE_STATUS_MAP.status.delLoading;
    }

    // 已停止
    if (!ready) {
        return NOTE_STATUS_MAP.status.stopped;
    }

    // 正在启动
    if (pending === 'spawn') {
        return NOTE_STATUS_MAP.status.startLoading;
    }

    // 正在停止
    if (pending === 'stop') {
        return NOTE_STATUS_MAP.status.stopLoading;
    }

    // 正在运行
    if (ready) {
        return NOTE_STATUS_MAP.status.running;
    }

}
